<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Sifteo SDK: Sifteo::TimeDelta Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style-overrides.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<center>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Sifteo SDK" src="sdk_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">v1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</center>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li><a href="pages.html"><span>Guides</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>Sifteo</b></li><li class="navelem"><a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="class_sifteo_1_1_time_delta-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Sifteo::TimeDelta Class Reference<div class="ingroups"><a class="el" href="group__time.html">Time</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Represents a difference between two SystemTimes, with moderate resolution.  
 <a href="class_sifteo_1_1_time_delta.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="time_8h_source.html">sifteo/time.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:ab527a1b29c8d05c27ad072e0da80e00a"><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#ab527a1b29c8d05c27ad072e0da80e00a">frames</a> (<a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a> duration) const </td></tr>
<tr class="memdesc:ab527a1b29c8d05c27ad072e0da80e00a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the number of frames, of a particular duration, that are represented by this time delta, rounding down.  <a href="#ab527a1b29c8d05c27ad072e0da80e00a">More...</a><br/></td></tr>
<tr class="separator:ab527a1b29c8d05c27ad072e0da80e00a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a515380afeb634d26e331cef379007093"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#a515380afeb634d26e331cef379007093">isNegative</a> () const </td></tr>
<tr class="memdesc:a515380afeb634d26e331cef379007093"><td class="mdescLeft">&#160;</td><td class="mdescRight">Is this time value negative?  <a href="#a515380afeb634d26e331cef379007093">More...</a><br/></td></tr>
<tr class="separator:a515380afeb634d26e331cef379007093"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab037377902a34d297dba5662e1526de2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab037377902a34d297dba5662e1526de2"></a>
bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#ab037377902a34d297dba5662e1526de2">isPositive</a> () const </td></tr>
<tr class="memdesc:ab037377902a34d297dba5662e1526de2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Is this time value positive? <br/></td></tr>
<tr class="separator:ab037377902a34d297dba5662e1526de2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a95f392559b8375a0c60c75febcc92ecc"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a95f392559b8375a0c60c75febcc92ecc"></a>
int32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#a95f392559b8375a0c60c75febcc92ecc">milliseconds</a> () const </td></tr>
<tr class="memdesc:a95f392559b8375a0c60c75febcc92ecc"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the delta in milliseconds. <br/></td></tr>
<tr class="separator:a95f392559b8375a0c60c75febcc92ecc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a04f4551d0b70ac9c8ef0928c629ffba2"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a04f4551d0b70ac9c8ef0928c629ffba2"></a>
int64_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#a04f4551d0b70ac9c8ef0928c629ffba2">nanoseconds</a> () const </td></tr>
<tr class="memdesc:a04f4551d0b70ac9c8ef0928c629ffba2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the delta in nanoseconds. <br/></td></tr>
<tr class="separator:a04f4551d0b70ac9c8ef0928c629ffba2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af8770f74d8edb37ae2a8876942728654"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af8770f74d8edb37ae2a8876942728654"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#af8770f74d8edb37ae2a8876942728654">operator double</a> () const </td></tr>
<tr class="memdesc:af8770f74d8edb37ae2a8876942728654"><td class="mdescLeft">&#160;</td><td class="mdescRight">Explicit converstion to double. <br/></td></tr>
<tr class="separator:af8770f74d8edb37ae2a8876942728654"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a42a2b963fc435bbb7e64ac5e7fee254c"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a42a2b963fc435bbb7e64ac5e7fee254c"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#a42a2b963fc435bbb7e64ac5e7fee254c">operator float</a> () const </td></tr>
<tr class="memdesc:a42a2b963fc435bbb7e64ac5e7fee254c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Explicit conversion to float. <br/></td></tr>
<tr class="separator:a42a2b963fc435bbb7e64ac5e7fee254c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acb4e39461ada764aae5b341c495db9ff"><td class="memItemLeft" align="right" valign="top">unsigned&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#acb4e39461ada764aae5b341c495db9ff">pullFrames</a> (<a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a> duration)</td></tr>
<tr class="memdesc:acb4e39461ada764aae5b341c495db9ff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return a frame count, and subtract (pull) the time corresponding with those frames from this <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a>.  <a href="#acb4e39461ada764aae5b341c495db9ff">More...</a><br/></td></tr>
<tr class="separator:acb4e39461ada764aae5b341c495db9ff"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a54c55623a3481d1bd98cebd140e6be11"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a54c55623a3481d1bd98cebd140e6be11"></a>
float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#a54c55623a3481d1bd98cebd140e6be11">seconds</a> () const </td></tr>
<tr class="memdesc:a54c55623a3481d1bd98cebd140e6be11"><td class="mdescLeft">&#160;</td><td class="mdescRight">Return the delta in seconds, as a floating point value. <br/></td></tr>
<tr class="separator:a54c55623a3481d1bd98cebd140e6be11"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0d43fed7065286e7022986ab94c3b73d"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#a0d43fed7065286e7022986ab94c3b73d">TimeDelta</a> (float sec)</td></tr>
<tr class="memdesc:a0d43fed7065286e7022986ab94c3b73d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a new <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a> from a floating point time, in seconds.  <a href="#a0d43fed7065286e7022986ab94c3b73d">More...</a><br/></td></tr>
<tr class="separator:a0d43fed7065286e7022986ab94c3b73d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:ade74c99a058eff9a6ac11cf7201f5812"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ade74c99a058eff9a6ac11cf7201f5812"></a>
static <a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#ade74c99a058eff9a6ac11cf7201f5812">fromMillisec</a> (int32_t m)</td></tr>
<tr class="memdesc:ade74c99a058eff9a6ac11cf7201f5812"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a new <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a> from an integer time, in milliseconds. <br/></td></tr>
<tr class="separator:ade74c99a058eff9a6ac11cf7201f5812"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8e4f14ebcc8b25a68fe7b3d3a130fe0e"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="class_sifteo_1_1_time_delta.html#a8e4f14ebcc8b25a68fe7b3d3a130fe0e">hz</a> (float h)</td></tr>
<tr class="memdesc:a8e4f14ebcc8b25a68fe7b3d3a130fe0e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a> representing the period which corresponds with a given frequency.  <a href="#a8e4f14ebcc8b25a68fe7b3d3a130fe0e">More...</a><br/></td></tr>
<tr class="separator:a8e4f14ebcc8b25a68fe7b3d3a130fe0e"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Represents a difference between two SystemTimes, with moderate resolution. </p>
<p>Deltas are internally stored as 32-bit millisecond counts, but they can be converted to many other units.</p>
<p>TimeDeltas can be directly compared to floating point values efficiently. In cases where the comparison is made against a constant, we can convert the entire operation to integer math at compile-time. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a0d43fed7065286e7022986ab94c3b73d"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">Sifteo::TimeDelta::TimeDelta </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>sec</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Construct a new <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a> from a floating point time, in seconds. </p>
<p>These constructors also provide an implicit conversion that makes tests like "delta &lt; 1.5" work. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="ab527a1b29c8d05c27ad072e0da80e00a"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">unsigned Sifteo::TimeDelta::frames </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a>&#160;</td>
          <td class="paramname"><em>duration</em></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return the number of frames, of a particular duration, that are represented by this time delta, rounding down. </p>
<p>This is integer division with truncation.</p>
<p>You can use this to implement animations which start at a particular reference point. At each frame, look at the current time, subtract the reference <a class="el" href="class_sifteo_1_1_system_time.html" title="Absolute time, measured by the system&#39;s monotonically increasing nanosecond timer.">SystemTime</a> to yield a <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a>, then use <a class="el" href="class_sifteo_1_1_time_delta.html#ab527a1b29c8d05c27ad072e0da80e00a" title="Return the number of frames, of a particular duration, that are represented by this time delta...">frames()</a> to convert that value to an integer frame count. </p>

</div>
</div>
<a class="anchor" id="a8e4f14ebcc8b25a68fe7b3d3a130fe0e"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a> Sifteo::TimeDelta::hz </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>h</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Construct a <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a> representing the period which corresponds with a given frequency. </p>
<p>This can be used, for example, with <a class="el" href="class_sifteo_1_1_time_delta.html#ab527a1b29c8d05c27ad072e0da80e00a" title="Return the number of frames, of a particular duration, that are represented by this time delta...">frames()</a> in order to specify the frame rate in HZ (FPS) rather than in seconds. </p>

</div>
</div>
<a class="anchor" id="a515380afeb634d26e331cef379007093"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Sifteo::TimeDelta::isNegative </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Is this time value negative? </p>
<p>Time deltas are signed, but in many cases it makes sense to reject negative deltas. This predicate can be used quickly in ASSERTs. </p>

</div>
</div>
<a class="anchor" id="acb4e39461ada764aae5b341c495db9ff"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">unsigned Sifteo::TimeDelta::pullFrames </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="class_sifteo_1_1_time_delta.html">TimeDelta</a>&#160;</td>
          <td class="paramname"><em>duration</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Return a frame count, and subtract (pull) the time corresponding with those frames from this <a class="el" href="class_sifteo_1_1_time_delta.html" title="Represents a difference between two SystemTimes, with moderate resolution.">TimeDelta</a>. </p>
<p>This leaves the remainder, i.e. the time since the beginning of the current frame, in this Time Delta.</p>
<p>This can be used as an alternative to <a class="el" href="class_sifteo_1_1_time_delta.html#ab527a1b29c8d05c27ad072e0da80e00a" title="Return the number of frames, of a particular duration, that are represented by this time delta...">frames()</a> in cases where time is being accumulated frame-by-frame instead of being calculated based on a fixed reference point. This is also very handy for animating at a fixed rate or running a fixed timestep physics simulation, while saving the remainders for later. </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="time_8h_source.html">time.h</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
    <hr class="footer"/>
    <address class="footer">
        <p><a href="http://sifteo.com">Sifteo</a> SDK v1.0.0 <small>(see <a href="https://developers.sifteo.com/sifteosdk">all versions</a>)</small></p>
        <p>Last updated Wed Mar 27 2013, by <a href="http://www.stack.nl/~dimitri/doxygen">Doxygen</a></p>
    </address>
</body>
</html>
